home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
BUTTONS
/
XTOOLBTN
/
XPROCS.INT
< prev
next >
Wrap
Text File
|
1996-05-26
|
14KB
|
353 lines
{*******************************************************}
{ }
{ xTool - Component Collection }
{ }
{ Copyright (c) 1995 Stefan B÷ther }
{ }
{*******************************************************}
{
03.12.95 Added new RectXXXX functions from Golden Software Stefc
03.12.95 remove confict Int with Int_ Stefc
06.01.96 added sysTempPath and sysDelay Stefc
08.02.96 added dateDaysInMonth, dateYear, dateMonth, dateDay Stefc
08.02.96 added IsWin95 constant Stefc
21.02.96 added TMonth & TDay type Stefc
22.02.96 added strFileLoad & strFileSave Stefc
09.03.96 correct sysTempPath Stefc
09.03.96 added regXXXXX functions for access the registry Stefc
24.03.96 added IsWinNT constant Stefc
24.03.96 added SysMetric object Stefc
26.03.96 added dateQuicken for controling date input with keys Stefc
27.03.96 added TDesktopCanvas here Stefc
28.03.96 added LoadDIBitmap Stefc
01.04.96 added Question function here Stefc
09.04.96 added sysSaverRunning added Stefc
12.04.96 added timeZoneOffset Stefc
12.04.96 added timeToInt Stefc
17.04.96 added strCmdLine Stefc
17.04.96 added rectBounds Stefc
17.04.96 added TPersistentRect class Stefc
19.04.96 added strDebug method Stefc
21.04.96 changed TMonth added noneMonth km
21.04.96 added licence callback Stefc
21.04.96 added strNiceDateDefault km
21.04.96 added simple strEncrpyt & strDecrypt Stefc
24.04.96 backport to 16 bit Stefc
24.04.96 added Information method Stefc
24.04.96 use win messageBox with Win95 in Question & Information Stefc
09.05.96 new function ExtractName Stefc
10.05.96 Added TPersistentRegistry Stefc
12.05.96 fileExec Stefc
14.05.96 New function Confirmation Stefc
16.05.96 New function strChange Stefc
}
unit xProcs;
interface
uses
{$IFDEF Win32} Windows, Registry, {$ELSE} WinTypes, WinProcs, {$ENDIF}
Messages, Classes, Graphics;
type
Float = Extended;
{$IFDEF Win32}
Int_ = Integer;
{$ELSE}
Int_ = Longint;
{$ENDIF}
const
XCOMPANY = 'Fabula Software';
const
{ several important ASCII codes }
NULL = #0;
BACKSPACE = #8;
TAB = #9;
LF = #10;
CR = #13;
ESC = #27;
BLANK = #32;
SPACE = BLANK;
{ digits as chars }
ZERO = '0'; ONE = '1'; TWO = '2'; THREE = '3'; FOUR = '4';
FIVE = '5'; SIX = '6'; SEVEN = '7'; EIGHT = '8'; NINE = '9';
{ special codes }
SLASH = '\'; { used in filenames }
HEX_PREFIX = '$'; { prefix for hexnumbers }
CRLF : PChar = #13#10;
{ computer sizes }
KBYTE = Sizeof(Byte) shl 10;
MBYTE = KBYTE shl 10;
GBYTE = MBYTE shl 10;
{ Low floating point value }
FLTZERO : Float = 0.00000001;
DIGITS : set of Char = [ZERO..NINE];
{ important registry keys / items }
REG_CURRENT_VERSION = 'Software\Microsoft\Windows\CurrentVersion';
REG_CURRENT_USER = 'RegisteredOwner';
REG_CURRENT_COMPANY = 'RegisteredOrganization';
type
TMonth = (NoneMonth,January,February,March,April,May,June,July,
August,September,October,November,December);
TDayOfWeek = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday);
TLicCallback = function ( var Code: Integer): Integer;
TBit = 0..31;
var
IsWin95,
IsWinNT : Boolean;
IsFabula : TLicCallBack;
{ bit manipulating }
function bitSet(const Value: Int_; const TheBit: TBit): Boolean;
function bitOn(const Value: Int_; const TheBit: TBit): Int_;
function bitOff(const Value: Int_; const TheBit: TBit): Int_;
function bitToggle(const Value: Int_; const TheBit: TBit): Int_;
{ String functions }
function strCut(const S: String; Len: Integer): String;
function strTrim(const S: String): String;
function strTrimA(const S: String): String;
function strTrimChA(const S: String; C: Char): String;
function strTrimChL(const S: String; C: Char): String;
function strTrimChR(const S: String; C: Char): String;
function strLeft(const S: String; Len: Integer): String;
function strLower(const S: String): String;
function strMake(C: Char; Len: Integer): String;
function strPadChL(const S: String; C: Char; Len: Integer): String;
function strPadChR(const S: String; C: Char; Len: Integer): String;
function strPadChC(const S: String; C: Char; Len: Integer): String;
function strPadL(const S: String; Len: Integer): String;
function strPadR(const S: String; Len: Integer): String;
function strPadC(const S: String; Len: Integer): String;
function strPadZeroL(const S: String; Len: Integer): String;
procedure strChange(var S:String; const Source, Dest: String);
function strRight(const S: String; Len: Integer): String;
function strAddSlash(const S: String): String;
function strDelSlash(const S: String): String;
function strSpace(Len: Integer): String;
function strToken(var S: String; Seperator: Char): String;
function strTokenCount(S: String; Seperator: Char): Integer;
function strTokenAt(const S:String; Seperator: Char; At: Integer): String;
function strUpper(const S: String): String;
function strOemAnsi(const S:String): String;
function strAnsiOem(const S:String): String;
function strEqual(const S1,S2: String): Boolean;
function strComp(const S1,S2: String): Boolean;
function strCompU(const S1,S2: String): Boolean;
function strNiceNum(const S: String): String;
function strNiceDateDefault(const S, Default: String): String;
function strNiceDate(const S: String): String;
function strNiceTime(const S: String): String;
function strReplace(const S: String; C: Char; const Replace: String): String;
function strCmdLine: String;
procedure strDebug(const S: String);
function strEncrypt(const S: String; Key: Word): String;
function strDecrypt(const S: String; Key: Word): String;
function strLastCh(const S: String): Char;
procedure strStripLast(var S: String);
function strByteSize(Value: Longint): String;
{$IFDEF Win32}
function strFileLoad(const aFile: String): String;
procedure strFileSave(const aFile,aString: String);
{$ENDIF}
{ Integer functions }
function intCenter(a,b: Int_): Int_;
function intMax(a,b: Int_): Int_;
function intMin(a,b: Int_): Int_;
function intPow(Base,Expo: Integer): Int_;
function intPow10(Exponent: Integer): Int_;
function intSign(a: Int_): Integer;
function intZero(a: Int_; Len: Integer): String;
{ Floatingpoint functions }
function fltAdd(P1,P2: Float; Decimals: Integer): Float;
function fltDiv(P1,P2: Float; Decimals: Integer): Float;
function fltEqual(P1,P2: Float; Decimals: Integer): Boolean;
function fltEqualZero(P: Float): Boolean;
function fltGreaterZero(P: Float): Boolean;
function fltLessZero(P: Float): Boolean;
function fltNeg(P: Float; Negate: Boolean): Float;
function fltMul(P1,P2: Float; Decimals: Integer): Float;
function fltRound(P: Float; Decimals: Integer): Float;
function fltSub(P1,P2: Float; Decimals: Integer): Float;
function fltUnEqualZero(P: Float): Boolean;
function fltCalc(const Expr: String): Float;
function fltPower(a,n: Float): Float;
{ Rectangle functions from Golden Software }
function rectHeight(const R: TRect): Integer;
function rectWidth(const R: TRect): Integer;
procedure rectGrow(var R: TRect; Delta: Integer);
procedure rectRelativeMove(var R: TRect; DX, DY: Integer);
procedure rectMoveTo(var R: TRect; X, Y: Integer);
function rectSet(Left, Top, Right, Bottom: Integer): TRect;
function rectInclude(const R1, R2: TRect): Boolean;
function rectPoint(const R: TRect; P: TPoint): Boolean;
function rectSetPoint(const TopLeft, BottomRight: TPoint): TRect;
function rectIntersection(const R1, R2: TRect): TRect;
function rectIsIntersection(const R1, R2: TRect): Boolean;
function rectIsValid(const R: TRect): Boolean;
function rectsAreValid(const Arr: array of TRect): Boolean;
function rectNull: TRect;
function rectIsNull(const R: TRect): Boolean;
function rectIsSquare(const R: TRect): Boolean;
function rectCentralPoint(const R: TRect): TPoint;
function rectBounds(aLeft,aTop,aWidth,aHeight: Integer): TRect;
{ date functions }
function dateYear(D: TDateTime): Integer;
function dateMonth(D: TDateTime): Integer;
function dateDay(D: TDateTime): Integer;
function dateBeginOfYear(D: TDateTime): TDateTime;
function dateEndOfYear(D: TDateTime): TDateTime;
function dateBeginOfMonth(D: TDateTime): TDateTime;
function dateEndOfMonth(D: TDateTime): TDateTime;
function dateWeekOfYear(D: TDateTime): Integer;
function dateDayOfYear(D: TDateTime): Integer;
function dateDayOfWeek(D: TDateTime): TDayOfWeek;
function dateLeapYear(D: TDateTime): Boolean;
function dateBeginOfQuarter(D: TDateTime): TDateTime;
function dateEndOfQuarter(D: TDateTime): TDateTime;
function dateBeginOfWeek(D: TDateTime;Weekday: Integer): TDateTime;
function dateDaysInMonth(D: TDateTime): Integer;
function dateQuicken(D: TDateTime; Key: Char): TDateTime;
{ time functions }
function timeHour(T: TDateTime): Integer;
function timeMin(T: TDateTime): Integer;
function timeSec(T: TDateTime): Integer;
function timeToInt(T: TDateTime): Integer;
{$IFDEF Win32}
function timeZoneOffset: Integer;
{$ENDIF}
{ file functions }
procedure fileShredder(const Filename: String);
function fileSize(const Filename: String): Longint;
function fileWildcard(const Filename: String): Boolean;
{$IFDEF Win32}
function fileTemp(const aExt: String): String;
function fileExec(const aCmdLine: String; aHide, aWait: Boolean): Boolean;
{$ENDIF}
function ExtractName(const Filename: String): String;
{ system functions }
function sysTempPath:String;
procedure sysDelay(aMs: Longint);
{$IFDEF Win32}
procedure sysSaverRunning(Active: Boolean);
{$ENDIF}
{ registry functions }
{$IFDEF Win32}
function regReadString(aKey: hKey; const Path: String): String;
procedure regWriteString(aKey: hKey; const Path,Value: String);
function regInfoString(const Value: String): String;
function regCurrentUser: String;
function regCurrentCompany: String;
{$ENDIF}
{ several functions }
function Question(const Msg: String):Boolean;
procedure Information(const Msg: String);
function Confirmation(const Msg: String): Word;
type
{ TRect that can be used persistent as property for components }
TUnitConvertEvent = function (Sender: TObject;
Value: Integer; Get: Boolean): Integer of object;
TPersistentRect = class(TPersistent)
public
constructor Create;
procedure Assign(Source: TPersistent); override;
property Rect: TRect read FRect;
property OnConvert: TUnitConvertEvent read FOnConvert write FOnConvert;
published
property Left : Integer read GetLeft write SetLeft;
property Top : Integer read GetTop write SetTop;
property Height: Integer read GetHeight write SetHeight;
property Width : Integer read GetWidth write SetWidth;
end;
{$IFDEF Win32}
{ Persistent access of components from the registry }
TPersistentRegistry = class(TRegistry)
public
function ReadComponent(const Name: String; Owner, Parent: TComponent): TComponent;
procedure WriteComponent(const Name: String; Component: TComponent);
end;
{$ENDIF
{ easy access of the system metrics }
TSystemMetric = class
protected
constructor Create;
procedure Update;
public
property MenuHeight: Integer read FMenuHeight;
property CaptionHeight: Integer read FCaptionHeight;
property Border: TPoint read FBorder;
property Frame: TPoint read FFrame;
property DlgFrame: TPoint read FDlgFrame;
property Bitmap: TPoint read FBitmap;
property HScroll: TPoint read FHScroll;
property VScroll: TPoint read FVScroll;
property Thumb: TPoint read FThumb;
property FullScreen: TPoint read FFullScreen;
property Min: TPoint read FMin;
property MinTrack: TPoint read FMinTrack;
property Cursor: TPoint read FCursor;
property Icon: TPoint read FIcon;
property DoubleClick: TPoint read FDoubleClick;
property IconSpacing: TPoint read FIconSpacing;
end;
var
SysMetric: TSystemMetric;
type
TDesktopCanvas = class(TCanvas)
public
constructor Create;
destructor Destroy; override;
end;
implementation